<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('sup list')" />
	<th:block th:include="include :: layout-latest-css" />
	<th:block th:include="include :: ztree-css" />
</head>
<body class="gray-bg">
	<div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="form">
					<input type="hidden" id="pageFlag" name="pageFlag" th:value="${sup.pageFlag}"/>
					<input type="hidden" id="type" name="type" th:value="${sup.type}"/>
					<div class="select-list">
						<ul>
							<li class="select-time">
								<label>考核月份： </label>
								<input type="text" class="" id="monthId" name="monthId" th:value="${sup.monthId}"/>
							</li>
							<li>
								被考核单位：
								<select name="dept.deptId" id="dept.deptId">
									<option value="">--请选择--</option>
									<option th:each="dept : ${deptList}" th:text="${dept.deptName}" th:value="${dept.deptId}"
										th:selected="${sup.dept.deptId == dept.deptId}" />
								</select>
							</li>
							<li>
								类型：
								<select name="type" id="type" th:with="dicts=${@dict.getType('rate_sup_type')}">
									<option value="">--请选择--</option>
									<option th:each="dict : ${dicts}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"
										th:selected="${sup.type == dict.dictValue}"></option>
								</select>
							</li>
							<!-- 
							<li>
								状态：
								<select name="status" id="status" th:with="dicts=${@dict.getType('rate_kh_status')}">
									<option value="">--请选择--</option>
									<option th:each="dict : ${dicts}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"
										th:selected="${sup.status == dict.dictValue}"></option>
								</select>
							</li>
							 -->
							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			<div class="btn-group-sm" id="toolbar" role="group" th:if="${'SUBMIT' == sup.pageFlag}">
				<a class="btn btn-success" onclick="add('JF')">
					<i class="fa "></i> 【新增专项加分】
				</a>
				&nbsp;&nbsp;&nbsp;&nbsp;
				<a class="btn btn-warning" onclick="add('KF')">
					<i class="fa "></i> 【新增专项扣分】
				</a>
				&nbsp;&nbsp;&nbsp;&nbsp;
				<a class="btn btn-danger" onclick="add('FMQD')">
					<i class="fa "></i> 【新增负面清单】
				</a>
				&nbsp;&nbsp;&nbsp;&nbsp;
				<a class="btn btn-info" onclick="add('SZPY')">
					<i class="fa "></i> 【新增述职评议】
				</a>
				&nbsp;&nbsp;&nbsp;&nbsp;
				<a class="btn btn-info" onclick="add('KHB')">
					<i class="fa "></i> 【新增考核办考核】
				</a>
			</div>
			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table"></table>
			</div>
		</div>
	</div>
	
	<th:block th:include="include :: footer" />
	<th:block th:include="include :: layout-latest-js" />
	<th:block th:include="include :: datetimepicker-css" />
	<th:block th:include="include :: datetimepicker-js" />
	<script th:inline="javascript">
		var prefix = ctx + "rate/sup";
		var typeDict = [[${@dict.getType('rate_sup_type')}]];
		var pageFlag = [[${sup.pageFlag}]];
		var type = [[${sup.type}]];

		$(function() {
			$("#monthId").datetimepicker({
				format: 'yyyy-mm',
				weekStart: 1,
				autoclose: true,
				startView: 3,
				minView: 3
			});
			list();
		});

		function list() {
			var cols = [];
			cols.push({
				checkbox: true
			});
			cols.push({
				field: 'id',
				visible: false
			});
			cols.push({
				field: 'monthId',
				align: 'center',
				title: '考评月份'
			});
			cols.push({
				field: 'dept.deptName',
				align: 'center',
				title: '被考核部门'
			});
			cols.push({
				field: 'type',
				align: 'center',
				title: '类型',
				formatter: function(value, row, index) {
					return $.table.selectDictLabel(typeDict, value);
				}
			});
			
			cols.push({
				field: 'score',
				align: 'center',
				title: '分数',
				formatter: function(value, row, index) {
					if (row.type == "FMQD") {
						return "N/A";
					} else {
						return value;
					}
				}
			});
			/**
			cols.push({
				field: 'createUser.userName',
				align: 'center',
				title: '提交人'
			});
			**/
			cols.push({
				field: 'createTime',
				align: 'center',
				title: '提交时间'
			});
			cols.push({
				title: '操作',
				align: 'center',
				width: '30%',
				formatter: function(value, row, index) {
					var status = row.status;
					
					var actions = [];
					if ("SUBMIT" == pageFlag) {
						actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
						actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="remove1(\'' + row.id + '\')"><i class="fa fa-times"></i>删除</a> ');
					}
					actions.push('<a class="btn btn-primary btn-xs" href="javascript:void(0)" onclick="view(\'' + row.id + '\')"><i class="fa fa-query"></i>查看</a> ');
					return actions.join('');
				}
			});
			
			var options = {
				url: prefix + "/list",
				modalName: "sup",
				columns: cols
			};
			$.table.init(options);
		}
		
		function add(type1) {
			$.modal.open("新增",
					prefix + "/add?pageFlag=ADD&type=" + type1);
		}
		function edit(id) {
			$.modal.open("修改",
					prefix + "/edit?id=" + id + "&pageFlag=EDIT");
		}
		/**
		function submitToCheck(id) {
			$.modal.confirm("确认要提交该条记录吗?", function() {
				var url = prefix + "/submitToCheck";
				var data = {"timestamp": new Date().getTime(), "id": id};
				$.operate.submit(url, "post", "json", data);
			});
		}
		function batchCancel() {
			var rows = $.common.isEmpty(table.options.uniqueId) ? $.table.selectFirstColumns() : $.table.selectColumns(table.options.uniqueId);
			if (rows.length == 0) {
				$.modal.alertWarning("请至少选择一条记录");
				return;
			}
			
			$.modal.confirm("确认要将选中的【" + rows.length + "】条数据批量撤回吗?", function() {
				var url = prefix + "/batchCancel";
				var data = { "ids": rows.join(), "pageFlag": pageFlag};
				$.operate.submit(url, "post", "json", data);
			});
		}
		function batchSubmitToCheck() {
			var rows = $.common.isEmpty(table.options.uniqueId) ? $.table.selectFirstColumns() : $.table.selectColumns(table.options.uniqueId);
			if (rows.length == 0) {
				$.modal.alertWarning("请至少选择一条记录");
				return;
			}
			
			$.modal.confirm("确认要将选中的【" + rows.length + "】条数据批量提交审核吗?", function() {
				var url = prefix + "/batchSubmitToCheck";
				var data = { "ids": rows.join(), "pageFlag": pageFlag};
				$.operate.submit(url, "post", "json", data);
			});
		}
		function cancelSubmit(id) {
			$.modal.confirm("确认要撤回该条记录吗?", function() {
				var url = prefix + "/cancelSubmit";
				var data = {"timestamp": new Date().getTime(), "id": id};
				$.operate.submit(url, "post", "json", data);
			});
		}
		function check(pageFlag, id) {
            $.modal.open("审批",
                prefix + "/edit?id=" + id + "&pageFlag=" + pageFlag);
        }
        function cancelCheck(pageFlag, id) {
            $.modal.confirm("确认要撤销审批该条记录吗?", function() {
                var url = prefix + "/cancelCheck";
                var data = {"timestamp": new Date().getTime(), "id": id, "pageFlag": pageFlag};
                $.operate.submit(url, "post", "json", data);
            });
        }
        **/
		function view(id) {
			$.modal.open("查看",
					prefix + "/edit?id=" + id + "&pageFlag=VIEW");
		}
		function remove1(id) {
			$.modal.confirm("确认要删除该条记录吗?", function() {
				var url = prefix + "/delete/" + id;
				var data = {"timestamp": new Date().getTime()};
				$.operate.submit(url, "post", "json", data);
			});
		}
		/**
		function batchSubmitCheck() {
			var rows = $.common.isEmpty(table.options.uniqueId) ? $.table.selectFirstColumns() : $.table.selectColumns(table.options.uniqueId);
			if (rows.length == 0) {
				$.modal.alertWarning("请至少选择一条记录");
				return;
			}
			
			var checkResult = $("#checkResult").val();
			if (checkResult == null || checkResult == "") {
				$.modal.alertWarning("请选择审核结果。");
				return;
			}
			
			// khz need to check fgld
			var fgld = "";
			if (pageFlag == "KHZ") {
				fgld = $("#fgldChecker").val();
				if (fgld == null || fgld == "") {
					$.modal.alertWarning("请选择下一级审批的分管领导。");
					return;
				}
			}
			
			$.modal.confirm("确认要将选中的【" + rows.length + "】条数据批量审核通过吗?", function() {
				var url = prefix + "/batchSubmitCheck";
				var data = { "ids": rows.join(), "pageFlag": pageFlag, "checkResult": checkResult, "fgldChecker.userId": fgld };
				$.operate.submit(url, "post", "json", data);
			});
		}
		**/
	</script>
</body>
</html>